<?php
$today = date('Y-m-d');
$today_ts = strtotime($today);
$yesterday = strtotime(date("Y-m-d", strtotime($today)) . " -1 day");
$yesterday = strftime("%Y-%m-%d", $yesterday);
$odd_sx = Frontend::findOddSxMB($today_ts, $yesterday, 1);
?>
<div class="span14">
    <legend>Dự đoán kết quả sổ xố</legend>

    <div class="clear"></div>

    <select id="location">
        <option value="1">Miền Bắc</option>
        <option value="2">Miền Nam</option>
    </select>

    <select id="type">
        <option value="1">Đề</option>
        <option value="2">Lô</option>
    </select>

    <div class="clear"></div>

    <?php for ($i = 0; $i < 100; $i++) { ?>
        <a href="javascript:void(0)" class="btn bt-reg1" onclick="addoddsx('<?php echo $i; ?>')">
            <?php
            if ($i >= 0 && $i < 10) {
                echo "0" . $i;
            } else {
                echo $i;
            }
            ?></a>
    <?php } ?>
</div>
<div class="clear"></div>
<div class="span12">
    <legend>Kết quả xổ số</legend>
    <div class="clear"></div>
    <select id="_location">
        <option value="1">Miền Bắc</option>
        <option value="2">Miền Nam</option>
    </select>
    <div id="change">
        <table cellspacing="0" cellpadding="0" border="0" class="table table-bordered table-events">
            <?php
            foreach ($odd_sx as $_odd_sx) {
                $time = strftime("%d-%m-%Y", $_odd_sx["dateTS"]);
                $result = explode("|", $_odd_sx["value"]);
                ?>
                <thead>
                    <tr>
                        <th colspan="13"><h4>Mở thưởng ngày <?php echo $time; ?></h4>
                </th>
                </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><h5>Đặc Biệt</h5></td>
                        <td colspan="12"><?php echo $result[0] ?></td>
                    </tr>
                    <tr>
                        <td class="span-2 bol f1b"><h5>Giải Nhất</h5></td>
                        <td colspan="12"><?php echo $result[1] ?></td>
                    </tr>
                    <tr>
                        <td class="span-2 bol f1b"><h5>Giải Nhì</h5></td>
                        <td colspan="6"><?php echo $result[2] ?></td>
                        <td colspan="6"><?php echo $result[3] ?></td>
                    </tr>
                    <tr>
                        <td rowspan="2" class="span-2 bol f1b"><h5>Giải Ba</h5></td>
                        <td colspan="4"><?php echo $result[4] ?></td>
                        <td colspan="4"><?php echo $result[5] ?></td>
                        <td colspan="4"><?php echo $result[6] ?></td></tr>
                    <tr><td colspan="4"><?php echo $result[7] ?></td>
                        <td colspan="4"><?php echo $result[8] ?></td>
                        <td colspan="4"><?php echo $result[9] ?></td>
                    </tr>
                    <tr>
                        <td class="span-2 bol f1b"><h5>Giải Tư</h5></td>
                        <td colspan="3"><?php echo $result[10] ?></td>
                        <td colspan="3"><?php echo $result[11] ?></td>
                        <td colspan="3"><?php echo $result[12] ?></td>
                        <td colspan="3"><?php echo $result[13] ?></td>
                    </tr>
                    <tr>
                        <td rowspan="2" class="span-2 bol f1b"><h5>Giải Năm</h5></td>
                        <td colspan="4"><?php echo $result[14] ?></td>
                        <td colspan="4"><?php echo $result[15] ?></td>
                        <td colspan="4"><?php echo $result[16] ?></td></tr>
                    <tr><td colspan="4"><?php echo $result[17] ?></td>
                        <td colspan="4"><?php echo $result[18] ?></td>
                        <td colspan="4"><?php echo $result[19] ?></td>
                    </tr>
                    <tr>
                        <td class="span-2 bol f1b"><h5>Giải Sáu</h5></td>
                        <td colspan="4"><?php echo $result[20] ?></td>
                        <td colspan="4"><?php echo $result[21] ?></td>
                        <td colspan="4"><?php echo $result[22] ?></td>
                    </tr>
                    <tr>
                        <td class="span-2 bol f1b"><h5>Giải Bảy</h5></td>
                        <td colspan="3"><?php echo $result[23] ?></td>
                        <td colspan="3"><?php echo $result[24] ?></td>
                        <td colspan="3"><?php echo $result[25] ?></td>
                        <td colspan="3"><?php echo $result[26] ?></td>
                    </tr>
                </tbody>
            <?php } ?>
        </table>
    </div>
</div>
<script>
        $(document).ready(function() {
            $('#_location').change(function() {
                $.ajax({
                    // The link we are accessing.
                    url: "/ajax.php",
                    // The type of request.
                    type: "get",
                    data: "act=change_xoso&key=" + $('#_location').val(),
                    // The type of data that is getting returned.
                    dataType: "html",
                    error: function() {
                    },
                    success: function(strData) {
                        // Load the content in to the page.
                        $("#change").html(strData);
                    }
                });
            });
        });
</script>